package com.cacho.s2b.lesson.learn;

/**
 * @Description 循环里的continue=跳过本次循环后面的语句，直接进入下一次循环,break=跳出循环
 * @Author LingWei
 * @date 2024/1/13
 **/
public class LearnLoop {
    public static void main(String[] args) {
        // breakWay(); // 0,1,2,3,4,6,7,8,9
        // continueWay();
        String aryStr = "test";
        String[] parts = aryStr.split((","));
        zeroLength(parts);
    }

    public static void breakWay() {
        for (int i = 0; i < 10; i++) {
            if (i == 5) {
                // 如果i等于5时，使用continue跳过本次循环后面的语句，直接进入下一次循环
                continue;
            }
            System.out.print(i + ",");
            System.out.println("i==5时不会执行");
        }
        System.out.println();
    }

    public static void continueWay() {
        for (int i = 0; i < 10; i++) {
            if (i == 5) {
                System.out.println("break 之前的还是会处理");
                // 如果i等于5时，跳出整个循环
                break;
            }
            System.out.print(i + ",");
        }
    }

    public static void zeroLength(String[] parts) {
        for (int i = 0; i < parts.length; i++) {
            System.out.print(parts[i]);
        }
    }

}
